public class toString_method {

    private String name;
    private int catty;
    private float Yuan;

    public toString_method(String name,int catty,float Yuan){
        this.name = name;
        this.catty = catty;
        this.Yuan = Yuan;
    }

    @Override
    public String toString(){
        return name+"每斤"+Yuan+"元,买了"+catty+"斤，需要支付"+(catty*Yuan);
    }

    public static void main(String[] args){
        toString_method to = new toString_method("糖心富士",5,4.98f);
        System.out.println(to.toString());
    }
}
